/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author kpc1
 */

import java.util.*;
import java.io.*; 
import javax.swing.*;
import java.lang.String;
import java.lang.Object;

public class QuestionClass implements QuestionCollection{

    public String[] nextQuestion()
    {
        String[] store = new String[5];
        String line;

        try
        {
        
        BufferedReader inputStream = new BufferedReader(new FileReader("test.txt"));
        
        line = inputStream.readLine();  //reading a line from the file
        store[0] = line;
        
        line = inputStream.readLine();  //reading a line from the file
        store[1] = line;
        
        line = inputStream.readLine();  //reading a line from the file
        store[2] = line;
        
        line = inputStream.readLine();  //reading a line from the file
        store[3] = line;
        
        line = inputStream.readLine();  //reading a line from the file
        store[4] = line;       
        
    	}   //end try
        
        /** catch Exceptions */
    	catch(FileNotFoundException e)  
    	{
    		System.out.println("File " + "out.txt" + " not found");	
    	}
    	catch(IOException e) 
    	{
    		System.out.println("Error reading from file out.txt");
    	}
        return store;
    }
    
    public boolean CheckAnswer(boolean[] Choice, String Place)
    {
        String line = "";
        boolean[] check = new boolean[4];
 
        try
        {
        BufferedReader inputStream = new BufferedReader(new FileReader("test.txt"));
        while(line.equals(Place) == false)
        {
            line = inputStream.readLine();  //reading a line from the file
        }
        line = inputStream.readLine();

        char[] Store = new char[4];
        
        for(int i =0; i < 4; i++)
        {    
           Store[i] = line.charAt(i);

           if(Store[i] == '1')
           {
               check[i] = true;
           }
           else if(Store[i] == '0')
           {
               check[i] = false;
           }
    	}
        }//end try
        
        /** catch Exceptions */
    	catch(FileNotFoundException e)  
    	{
    		System.out.println("File " + "out.txt" + " not found");	
    	}
    	catch(IOException e) 
    	{
    		System.out.println("Error reading from file out.txt");
    	}
        

  
        for(int i = 0; i < 4; i++)
        {
            if (check[i] != Choice[i])
            {
                return false;
            }
        }
        return true;
      
    }
}
